<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="事项" prop="matter">
        <el-input
          v-model="queryParams.matter"
          placeholder="请输入事项"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="工号" prop="jobNumber">
        <el-input
          v-model="queryParams.jobNumber"
          placeholder="请输入工号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="部门" prop="department">
        <el-input
          v-model="queryParams.department"
          placeholder="请输入部门"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="项目经理" prop="projectManager">
        <el-input
          v-model="queryParams.projectManager"
          placeholder="请输入项目经理"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="所在城市" prop="liveCity">
        <el-input
          v-model="queryParams.liveCity"
          placeholder="请输入所在城市"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="所在项目组" prop="projectTeam">
        <el-input
          v-model="queryParams.projectTeam"
          placeholder="请输入所在项目组"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="所在项目负责人" prop="projectLeader">
        <el-input
          v-model="queryParams.projectLeader"
          placeholder="请输入所在项目负责人"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="姓名" prop="yname">
        <el-input
          v-model="queryParams.yname"
          placeholder="请输入姓名"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="正式员工/试用期" prop="employee">
        <el-input
          v-model="queryParams.employee"
          placeholder="请输入正式员工/试用期"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="是否请假" prop="leaveYesNo">
        <el-select v-model="queryParams.leaveYesNo" placeholder="请选择是否请假" clearable>
          <el-option
            v-for="dict in dict.type.sys_no_yes"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="请假天数" prop="leaveDays">
        <el-input
          v-model="queryParams.leaveDays"
          placeholder="请输入请假天数"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="调休假" prop="leaveInLieu">
        <el-input
          v-model="queryParams.leaveInLieu"
          placeholder="请输入调休假"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="年假" prop="annualLeave">
        <el-input
          v-model="queryParams.annualLeave"
          placeholder="请输入年假"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="事假" prop="personalLeave">
        <el-input
          v-model="queryParams.personalLeave"
          placeholder="请输入事假"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="请假天数" prop="rLeaveDays">
        <el-input
          v-model="queryParams.rLeaveDays"
          placeholder="请输入请假天数"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="联系方式" prop="contactInformation">
        <el-input
          v-model="queryParams.contactInformation"
          placeholder="请输入联系方式"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="春节回家目的地" prop="homeProvince">
        <el-input
          v-model="queryParams.homeProvince"
          placeholder="请输入春节回家目的地"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="春节回家目的地" prop="homeCity">
        <el-input
          v-model="queryParams.homeCity"
          placeholder="请输入春节回家目的地"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="出发日期" prop="dateDeparture">
        <el-date-picker clearable
                        v-model="queryParams.dateDeparture"
                        type="date"
                        value-format="yyyy-MM-dd"
                        placeholder="请选择出发日期">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="出行方式" prop="tripMode">
        <el-select v-model="queryParams.tripMode" placeholder="请选择出行方式" clearable>
          <el-option
            v-for="dict in dict.type.sys_trip_mode"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="出行车次" prop="travelRoutes">
        <el-input
          v-model="queryParams.travelRoutes"
          placeholder="请输入出行车次"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="回家路线" prop="pathProvince">
        <el-input
          v-model="queryParams.pathProvince"
          placeholder="请输入回家路线"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="回家路线" prop="pathCity">
        <el-input
          v-model="queryParams.pathCity"
          placeholder="请输入回家路线"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="预计到家时间" prop="estimatedTimeArrival">
        <el-date-picker clearable
                        v-model="queryParams.estimatedTimeArrival"
                        type="date"
                        value-format="yyyy-MM-dd"
                        placeholder="请选择预计到家时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="老家联系人" prop="hometownContactPerson">
        <el-input
          v-model="queryParams.hometownContactPerson"
          placeholder="请输入老家联系人"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="老家人联系方式" prop="hometownContactPersonPhone">
        <el-input
          v-model="queryParams.hometownContactPersonPhone"
          placeholder="请输入老家人联系方式"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="返回时间" prop="dateReturn">
        <el-date-picker clearable
                        v-model="queryParams.dateReturn"
                        type="date"
                        value-format="yyyy-MM-dd"
                        placeholder="请选择返回时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="返回方式" prop="returnWay">
        <el-select v-model="queryParams.returnWay" placeholder="请选择返回方式" clearable>
          <el-option
            v-for="dict in dict.type.sys_trip_mode"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="预计到岗时间" prop="expectedTimeArrival">
        <el-date-picker clearable
                        v-model="queryParams.expectedTimeArrival"
                        type="date"
                        value-format="yyyy-MM-dd"
                        placeholder="请选择预计到岗时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="是否到岗" prop="whetherWork">
        <el-select v-model="queryParams.whetherWork" placeholder="请选择是否到岗" clearable>
          <el-option
            v-for="dict in dict.type.sys_yes_no"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="实际到岗时间" prop="actualTimeArrival">
        <el-date-picker clearable
                        v-model="queryParams.actualTimeArrival"
                        type="date"
                        value-format="yyyy-MM-dd"
                        placeholder="请选择实际到岗时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['system:statistics:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['system:statistics:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['system:statistics:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['system:statistics:export']"
        >导出</el-button>
        <el-button
          type="info"
          icon="el-icon-upload2"
          size="mini"
          @click="handleImport"
        >导入</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="statisticsList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="注建" align="center" prop="staId" />
      <el-table-column label="事项" align="center" prop="matter" />
      <el-table-column label="工号" align="center" prop="jobNumber" />
      <el-table-column label="部门" align="center" prop="department" />
      <el-table-column label="项目经理" align="center" prop="projectManager" />
      <el-table-column label="所在城市" align="center" prop="liveCity" />
      <el-table-column label="所在项目组" align="center" prop="projectTeam" />
      <el-table-column label="所在项目负责人" align="center" prop="projectLeader" />
      <el-table-column label="姓名" align="center" prop="yname" />
      <el-table-column label="正式员工/试用期" align="center" prop="employee" />
      <el-table-column label="是否请假" align="center" prop="leaveYesNo">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.sys_no_yes" :value="scope.row.leaveYesNo"/>
        </template>
      </el-table-column>
      <el-table-column label="请假天数" align="center" prop="leaveDays" />
      <el-table-column label="调休假" align="center" prop="leaveInLieu" />
      <el-table-column label="年假" align="center" prop="annualLeave" />
      <el-table-column label="事假" align="center" prop="personalLeave" />
      <el-table-column label="请假天数" align="center" prop="rLeaveDays" />
      <el-table-column label="联系方式" align="center" prop="contactInformation" />
      <el-table-column label="春节回家目的地" align="center" prop="homeProvince" />
      <el-table-column label="春节回家目的地" align="center" prop="homeCity" />
      <el-table-column label="出发日期" align="center" prop="dateDeparture" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.dateDeparture, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="出行方式" align="center" prop="tripMode">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.sys_trip_mode" :value="scope.row.tripMode"/>
        </template>
      </el-table-column>
      <el-table-column label="出行车次" align="center" prop="travelRoutes" />
      <el-table-column label="回家路线" align="center" prop="pathProvince" />
      <el-table-column label="回家路线" align="center" prop="pathCity" />
      <el-table-column label="预计到家时间" align="center" prop="estimatedTimeArrival" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.estimatedTimeArrival, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="老家联系人" align="center" prop="hometownContactPerson" />
      <el-table-column label="老家人联系方式" align="center" prop="hometownContactPersonPhone" />
      <el-table-column label="返回时间" align="center" prop="dateReturn" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.dateReturn, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="返回方式" align="center" prop="returnWay">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.sys_trip_mode" :value="scope.row.returnWay"/>
        </template>
      </el-table-column>
      <el-table-column label="预计到岗时间" align="center" prop="expectedTimeArrival" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.expectedTimeArrival, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="是否到岗" align="center" prop="whetherWork">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.sys_yes_no" :value="scope.row.whetherWork"/>
        </template>
      </el-table-column>
      <el-table-column label="实际到岗时间" align="center" prop="actualTimeArrival" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.actualTimeArrival, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="备注" align="center" prop="remark" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['system:statistics:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['system:statistics:remove']"
          >删除</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-view"
            @click="handleView(scope.row)"
            v-hasPermi="['system:statistics:query']"
          >详情</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改节假日返乡统计对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="事项" prop="matter">
          <el-input v-model="form.matter" placeholder="请输入事项" />
        </el-form-item>
        <el-form-item label="工号" prop="jobNumber">
          <el-input v-model="form.jobNumber" placeholder="请输入工号" />
        </el-form-item>
        <el-form-item label="部门" prop="department">
          <el-input v-model="form.department" placeholder="请输入部门" />
        </el-form-item>
        <el-form-item label="项目经理" prop="projectManager">
          <el-input v-model="form.projectManager" placeholder="请输入项目经理" />
        </el-form-item>
        <el-form-item label="所在城市" prop="liveCity">
          <el-input v-model="form.liveCity" placeholder="请输入所在城市" />
        </el-form-item>
        <el-form-item label="所在项目组" prop="projectTeam">
          <el-input v-model="form.projectTeam" placeholder="请输入所在项目组" />
        </el-form-item>
        <el-form-item label="所在项目负责人" prop="projectLeader">
          <el-input v-model="form.projectLeader" placeholder="请输入所在项目负责人" />
        </el-form-item>
        <el-form-item label="姓名" prop="yname">
          <el-input v-model="form.yname" placeholder="请输入姓名" />
        </el-form-item>
        <el-form-item label="正式员工/试用期" prop="employee">
          <el-input v-model="form.employee" placeholder="请输入正式员工/试用期" />
        </el-form-item>
        <el-form-item label="是否请假" prop="leaveYesNo">
          <el-select v-model="form.leaveYesNo" placeholder="请选择是否请假">
            <el-option
              v-for="dict in dict.type.sys_no_yes"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="请假天数" prop="leaveDays">
          <el-input v-model="form.leaveDays" placeholder="请输入请假天数" />
        </el-form-item>
        <el-form-item label="调休假" prop="leaveInLieu">
          <el-input v-model="form.leaveInLieu" placeholder="请输入调休假" />
        </el-form-item>
        <el-form-item label="年假" prop="annualLeave">
          <el-input v-model="form.annualLeave" placeholder="请输入年假" />
        </el-form-item>
        <el-form-item label="事假" prop="personalLeave">
          <el-input v-model="form.personalLeave" placeholder="请输入事假" />
        </el-form-item>
        <el-form-item label="请假天数" prop="rLeaveDays">
          <el-input v-model="form.rLeaveDays" placeholder="请输入请假天数" />
        </el-form-item>
        <el-form-item label="联系方式" prop="contactInformation">
          <el-input v-model="form.contactInformation" placeholder="请输入联系方式" />
        </el-form-item>
        <el-form-item label="春节回家目的地（省）" prop="homeProvince">
          <el-input v-model="form.homeProvince" placeholder="请输入春节回家目的地（省）" />
        </el-form-item>
        <el-form-item label="春节回家目的地（市）" prop="homeCity">
          <el-input v-model="form.homeCity" placeholder="请输入春节回家目的地（市）" />
        </el-form-item>
        <el-form-item label="出发日期" prop="dateDeparture">
          <el-date-picker clearable
                          v-model="form.dateDeparture"
                          type="date"
                          value-format="yyyy-MM-dd"
                          placeholder="请选择出发日期">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="出行方式" prop="tripMode">
          <el-select v-model="form.tripMode" placeholder="请选择出行方式">
            <el-option
              v-for="dict in dict.type.sys_trip_mode"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="出行车次" prop="travelRoutes">
          <el-input v-model="form.travelRoutes" placeholder="请输入出行车次" />
        </el-form-item>
        <el-form-item label="回家路线（省）" prop="pathProvince">
          <el-input v-model="form.pathProvince" placeholder="请输入回家路线（省）" />
        </el-form-item>
        <el-form-item label="回家路线（市）" prop="pathCity">
          <el-input v-model="form.pathCity" placeholder="请输入回家路线（市）" />
        </el-form-item>
        <el-form-item label="预计到家时间" prop="estimatedTimeArrival">
          <el-date-picker clearable
                          v-model="form.estimatedTimeArrival"
                          type="date"
                          value-format="yyyy-MM-dd"
                          placeholder="请选择预计到家时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="老家联系人" prop="hometownContactPerson">
          <el-input v-model="form.hometownContactPerson" placeholder="请输入老家联系人" />
        </el-form-item>
        <el-form-item label="老家人联系方式" prop="hometownContactPersonPhone">
          <el-input v-model="form.hometownContactPersonPhone" placeholder="请输入老家人联系方式" />
        </el-form-item>
        <el-form-item label="返回时间" prop="dateReturn">
          <el-date-picker clearable
                          v-model="form.dateReturn"
                          type="date"
                          value-format="yyyy-MM-dd"
                          placeholder="请选择返回时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="返回方式" prop="returnWay">
          <el-select v-model="form.returnWay" placeholder="请选择返回方式">
            <el-option
              v-for="dict in dict.type.sys_trip_mode"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="预计到岗时间" prop="expectedTimeArrival">
          <el-date-picker clearable
                          v-model="form.expectedTimeArrival"
                          type="date"
                          value-format="yyyy-MM-dd"
                          placeholder="请选择预计到岗时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="是否到岗" prop="whetherWork">
          <el-select v-model="form.whetherWork" placeholder="请选择是否到岗">
            <el-option
              v-for="dict in dict.type.sys_yes_no"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="实际到岗时间" prop="actualTimeArrival">
          <el-date-picker clearable
                          v-model="form.actualTimeArrival"
                          type="date"
                          value-format="yyyy-MM-dd"
                          placeholder="请选择实际到岗时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="备注" prop="remark">
          <el-input v-model="form.remark" placeholder="请输入备注" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
    <!-- 任务日志详细 -->
    <el-dialog title="详细" :visible.sync="openView" width="700px" append-to-body>
      <el-form ref="form" :model="form" label-width="120px" size="mini">
        <el-row>
          <el-col :span="12">
            <el-form-item label="事项：">{{form.matter }}</el-form-item>
            <el-form-item label="工号：">{{form.jobNumber }}</el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="部门：">{{form.department}}</el-form-item>
            <el-form-item label="项目经理：">{{form.projectManager}}</el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="所在城市：">{{form.liveCity}}</el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="所在项目组：">{{form.projectTeam}}</el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="所在项目负责人：">{{form.projectLeader}}</el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="姓名：">{{form.yname}}</el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="正式员工/试用期：">{{form.employee}}</el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="是否请假：">{{form.leaveYesNo}}</el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="请假天数：">{{form.leaveDays}}</el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="调休假：">{{form.leaveInLieu}}</el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="年假：">{{form.annualLeave}}</el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="事假：">{{form.personalLeave}}</el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="请假天数2：">{{form.rLeaveDays}}</el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="联系方式：">{{form.contactInformation}}</el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="手机：">{{form.contactInformation}}</el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="春节回家目的地（省）	：">{{form.homeProvince}}</el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="春节回家目的地（市）	：">{{form.homeCity}}</el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="出发日期：">{{form.dateDeparture}}</el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="出行方式：">{{form.tripMode}}</el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="出行车次：">{{form.travelRoutes}}</el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="回家路线（省）：">{{form.pathProvince}}</el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="回家路线（市）：">{{form.pathCity}}</el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="预计到家时间：">{{form.estimatedTimeArrival}}</el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="老家联系人：">{{form.hometownContactPerson}}</el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="老家人联系方式：">{{form.hometownContactPersonPhone}}</el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="返回时间：">{{form.dateReturn}}</el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="返回方式：">{{form.returnWay}}</el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="预计到岗时间	：">{{form.expectedTimeArrival}}</el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="是否到岗	：">{{form.whetherWork}}</el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="实际到岗时间	：">{{form.actualTimeArrival}}</el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="备注	：">{{form.remark}}</el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="openView = false">关 闭</el-button>
      </div>
    </el-dialog>
    <!-- 导入对话框 -->
    <el-dialog :title="upload.title" :visible.sync="upload.open" width="400px">
      <el-upload
        ref="upload"
        :limit="1"
        accept=".xlsx, .xls"
        :headers="upload.headers"
        :action="upload.url + '?updateSupport=' + upload.updateSupport"
        :disabled="upload.isUploading"
        :on-progress="handleFileUploadProgress"
        :on-success="handleFileSuccess"
        :auto-upload="false"
        drag
      >
        <i class="el-icon-upload"></i>
        <div class="el-upload__text">
          将文件拖到此处，或
          <em>点击上传</em>
        </div>
        <div class="el-upload__tip" slot="tip">
          <el-checkbox v-model="upload.updateSupport" />是否更新已经存在的用户数据
          <el-link type="info" style="font-size:12px" @click="importTemplate">下载模板</el-link>
        </div>
        <div class="el-upload__tip" style="color:red" slot="tip">提示：仅允许导入“xls”或“xlsx”格式文件！</div>
      </el-upload>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitFileForm">确 定</el-button>
        <el-button @click="upload.open = false">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
  import { getToken } from "@/utils/auth";
  import { listStatistics, getStatistics, delStatistics, addStatistics, updateStatistics } from "@/api/system/statistics";

  export default {
    name: "Statistics",
    dicts: ['sys_yes_no', 'sys_trip_mode', 'sys_no_yes'],
    data() {
      return {
        // 遮罩层
        loading: true,
        // 选中数组
        ids: [],
        // 非单个禁用
        single: true,
        // 非多个禁用
        multiple: true,
        // 显示搜索条件
        showSearch: true,
        // 总条数
        total: 0,
        // 节假日返乡统计表格数据
        statisticsList: [],
        // 弹出层标题
        title: "",
        // 是否显示弹出层
        open: false,
        // 是否显示详细弹出层
        openView: false,
        // 导入参数
        upload: {
          // 是否显示弹出层（用户导入）
          open: false,
          // 弹出层标题（用户导入）
          title: "",
          // 是否禁用上传
          isUploading: false,
          // 是否更新已经存在的用户数据
          updateSupport: 0,
          // 设置上传的请求头部
          headers: { Authorization: "Bearer " + getToken() },
          // 上传的地址
          url: process.env.VUE_APP_BASE_API + "/system/statistics/importData"
        },
        // 查询参数
        queryParams: {
          pageNum: 1,
          pageSize: 10,
          matter: null,
          jobNumber: null,
          department: null,
          projectManager: null,
          liveCity: null,
          projectTeam: null,
          projectLeader: null,
          yname: null,
          employee: null,
          leaveYesNo: null,
          leaveDays: null,
          leaveInLieu: null,
          annualLeave: null,
          personalLeave: null,
          rLeaveDays: null,
          contactInformation: null,
          homeProvince: null,
          homeCity: null,
          dateDeparture: null,
          tripMode: null,
          travelRoutes: null,
          pathProvince: null,
          pathCity: null,
          estimatedTimeArrival: null,
          hometownContactPerson: null,
          hometownContactPersonPhone: null,
          dateReturn: null,
          returnWay: null,
          expectedTimeArrival: null,
          whetherWork: null,
          actualTimeArrival: null,
        },
        // 表单参数
        form: {},
        // 表单校验
        rules: {
        }
      };
    },
    created() {
      this.getList();
    },
    methods: {
      /** 查询节假日返乡统计列表 */
      getList() {
        this.loading = true;
        listStatistics(this.queryParams).then(response => {
          this.statisticsList = response.rows;
        this.total = response.total;
        this.loading = false;
      });

      },
      // 取消按钮
      cancel() {
        this.open = false;
        this.reset();
      },
      // 表单重置
      reset() {
        this.form = {
          staId: null,
          matter: null,
          jobNumber: null,
          department: null,
          projectManager: null,
          liveCity: null,
          projectTeam: null,
          projectLeader: null,
          yname: null,
          employee: null,
          leaveYesNo: null,
          leaveDays: null,
          leaveInLieu: null,
          annualLeave: null,
          personalLeave: null,
          rLeaveDays: null,
          contactInformation: null,
          homeProvince: null,
          homeCity: null,
          dateDeparture: null,
          tripMode: null,
          travelRoutes: null,
          pathProvince: null,
          pathCity: null,
          estimatedTimeArrival: null,
          hometownContactPerson: null,
          hometownContactPersonPhone: null,
          dateReturn: null,
          returnWay: null,
          expectedTimeArrival: null,
          whetherWork: null,
          actualTimeArrival: null,
          remark: null
        };
        this.resetForm("form");
      },
      /** 搜索按钮操作 */
      handleQuery() {
        this.queryParams.pageNum = 1;
        this.getList();
      },
      /** 重置按钮操作 */
      resetQuery() {
        this.resetForm("queryForm");
        this.handleQuery();
      },
      // 多选框选中数据
      handleSelectionChange(selection) {
        this.ids = selection.map(item => item.staId)
        this.single = selection.length!==1
        this.multiple = !selection.length
      },
      /** 新增按钮操作 */
      handleAdd() {
        this.reset();
        this.open = true;
        this.title = "添加节假日返乡统计";
      },
      /** 修改按钮操作 */
      handleUpdate(row) {
        this.reset();
        const staId = row.staId || this.ids
        getStatistics(staId).then(response => {
          this.form = response.data;
          alert(JSON.stringify(response.data));
        this.open = true;
        this.title = "修改节假日返乡统计";
      });
      },
      /** 提交按钮 */
      submitForm() {
        this.$refs["form"].validate(valid => {
          if (valid) {
            if (this.form.staId != null) {
              updateStatistics(this.form).then(response => {
                this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
            } else {
              addStatistics(this.form).then(response => {
                this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
            }
          }
        });
      },
      /** 删除按钮操作 */
      handleDelete(row) {
        const staIds = row.staId || this.ids;
        this.$modal.confirm('是否确认删除节假日返乡统计编号为"' + staIds + '"的数据项？').then(function() {
          return delStatistics(staIds);
        }).then(() => {
          this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
      },
      /** 任务详细信息 */
      handleView(row) {
        getStatistics(row.staId).then(response => {
          this.form = response.data;
          this.openView = true;
        });
      },
      /** 导出按钮操作 */
      handleExport() {
        this.download('system/statistics/export', {
          ...this.queryParams
      }, `statistics_${new Date().getTime()}.xlsx`)
      },
      /** 导入按钮操作 */
      handleImport() {
        this.upload.title = "导入";
        this.upload.open = true;
      },
      /** 下载模板操作 */
      importTemplate() {
        this.download('system/statistics/importTemplate', {
        }, `statistics_${new Date().getTime()}.xlsx`)
      },
      // 文件上传中处理
      handleFileUploadProgress(event, file, fileList) {
        this.upload.isUploading = true;
      },
      // 文件上传成功处理
      handleFileSuccess(response, file, fileList) {
        this.upload.open = false;
        this.upload.isUploading = false;
        this.$refs.upload.clearFiles();
        this.$alert("<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" + response.msg + "</div>", "导入结果", { dangerouslyUseHTMLString: true });
        this.getList();
      },
      // 提交上传文件
      submitFileForm() {
        this.$refs.upload.submit();
      }
    }
  };
</script>
